package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.CustomerReturnList;
import com.atguigu.jxc.service.CustomerReturnListGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * @author fenge
 */
@RequestMapping("customerReturnListGoods")
@Controller
public class CustomerReturnListGoodsController {

    @Autowired
    private CustomerReturnListGoodsService customerReturnListGoodsService;

    @PostMapping("save")
    @ResponseBody
    public ServiceVO save(CustomerReturnList customerReturnList, String customerReturnListGoodsStr, HttpSession session){
        customerReturnListGoodsService.save(customerReturnList,customerReturnListGoodsStr,session);
        return new ServiceVO(100,"请求成功");
    }

    @PostMapping("list")
    @ResponseBody
    public Map<String,Object> list(String returnNumber, Integer customerId, Integer state, String sTime, String eTime){
        return customerReturnListGoodsService.list(returnNumber,customerId,state,sTime,eTime);
    }

    @PostMapping("goodsList")
    @ResponseBody
    public Map<String,Object> goodsList(Integer customerReturnListId){
        return customerReturnListGoodsService.goodsList(customerReturnListId);
    }

    @PostMapping("delete")
    @ResponseBody
    public ServiceVO delete(Integer customerReturnListId){
        customerReturnListGoodsService.delete(customerReturnListId);
        return new ServiceVO(100,"请求成功");
    }

    @PostMapping("count")
    @ResponseBody
    public String count(String sTime, String eTime, Integer goodsTypeId, String codeOrName){
        return customerReturnListGoodsService.count(sTime,eTime,goodsTypeId,codeOrName);
    }
}
